package com.util;

import java.sql.*;
import java.util.ArrayList;

import com.entity.*;

public class SelectDao {
	//根据给的字段信息判断 验证存不存在
	public static boolean isexist() {
		boolean action = false;
		
		return action;
	}
	
	//根据给的字段信息查 all信息
	public static ArrayList<Deptrole> selectfromdeptname(String deptname) {
		ArrayList<Deptrole> allroles = null;
		PreparedStatement pst = null;
		ResultSet rs = null;
		Deptrole deptrole = null;
		String sql = "select * from deptrole where deptname=?;";
		try {
			pst = DBUtil.getConnection().prepareStatement(sql);
			pst.setString(1, deptname);
			rs = pst.executeQuery();
			allroles = new ArrayList<Deptrole>();
			while(rs.next()) {
				deptrole = new Deptrole();
				deptrole.setDeptid(rs.getInt("Deptid"));
				deptrole.setDeptname(rs.getString("Deptname"));
				deptrole.setRoleid(rs.getInt("Roleid"));
				deptrole.setRolename(rs.getString("Rolename"));
				deptrole.setCreatetime(rs.getString("Createtime"));
				deptrole.setBasewages(rs.getFloat("Basewages"));
				deptrole.setOvertimestandard(rs.getFloat("Overtimestandard"));
				deptrole.setLeavestandard(rs.getFloat("Leavestandard"));
				deptrole.setAbsentstandard(rs.getFloat("Absentstandard"));
				allroles.add(deptrole);
			}
		} catch(SQLException e) {
			e.printStackTrace();
		}
		
		return allroles ;
	}
	//
//	public static ArrayList<Deptrole> select() {
//		ArrayList<Deptrole> allroles = null;
//		PreparedStatement pst = null;
//		ResultSet rs = null;
//		Deptrole deptrole = null;
//		String sql = "select * from deptrole;";
//		try {
//			pst = DBUtil.getConnection().prepareStatement(sql);
//			rs = pst.executeQuery();
//			allroles = new ArrayList<Deptrole>();
//			while(rs.next()) {
//				deptrole = new Deptrole(
//						rs.getInt(1),
//						rs.getString(2),
//						rs.getInt(3),
//						rs.getString(4),
//						rs.getFloat(5),
//						rs.getFloat(6),
//						rs.getFloat(7),
//						rs.getFloat(8),
//						rs.getString(9),
//						rs.getString(10),
//						rs.getString(11),
//						rs.getString(12),
//						rs.getString(13)
//					);
//				allroles.add(deptrole);
//			}
//		} catch(SQLException e) {
//			e.printStackTrace();
//		}
//		
//		return allroles ;
//	}
}
